# -*- coding: utf-8 -*-
# __init__.py create by rabie
# on 2023/4/17
# desc



from datetime import timedelta

from jms.ods.sqs.label_management_config import jms_ods__label_management_config
from utils.operators.cluster_for_spark_sql_operator import SparkSqlOperator

jms_dim__dim_label_management_config_base = SparkSqlOperator(
    task_id='jms_dim__dim_label_management_config_base',
    task_concurrency=1,
    pool_slots=2,
    master='yarn',
    name='jms_dim__dim_label_management_config_base_{{ execution_date | date_add(1) | cst_ds }}',
    sql='jms/dim/sqs/dim_label_management_config_base/execute.sql',
    executor_cores=2,
    executor_memory='4G',
    email=['yl_etl@yl-scm.com','yl_bigdata@yl-scm.com'],
    num_executors=4,  # spark.dynamicAllocation.enabled 为 True 时，num_executors 表示最少 Executor 数
    conf={'spark.dynamicAllocation.enabled'                  : 'true',  # 动态资源开启
          'spark.shuffle.service.enabled'                    : 'true',  # 动态资源 Shuffle 服务开启
          'spark.dynamicAllocation.maxExecutors'             : 5,  # 动态资源最大扩容 Executor 数
          'spark.dynamicAllocation.cachedExecutorIdleTimeout': 60,  # 动态资源自动释放闲置 Executor 的超时时间(s)
          'spark.sql.sources.partitionOverwriteMode'         : 'dynamic',  # 允许删改已存在的分区
          'spark.executor.memoryOverhead'                    : '1G',  # 堆外内存
          'spark.sql.shuffle.partitions'                     : 20,
          },
    # hiveconf={'hive.exec.dynamic.partition'             : 'true',  # 动态分区
    #           'hive.exec.dynamic.partition.mode'        : 'nonstrict',
    #           'hive.exec.max.dynamic.partitions'        : 20,  # 每天生成 20 个分区
    #           'hive.exec.max.dynamic.partitions.pernode': 20,  # 每天生成 20 个分区
    #           },
    yarn_queue='pro',
    #execution_timeout=timedelta(hours=1)
    #excel平均时长:0
    execution_timeout = timedelta(minutes=30),
)
jms_dim__dim_label_management_config_base << jms_ods__label_management_config